<!DOCTYPE html> 
<html> 
	<head>
  <meta charset="UTF-8">	
	<title>Restaurant Picker</title> 
	
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="jquery.mobile.structure-1.0.1.css" />
	<link rel="apple-touch-icon" href="images/launch_icon_57.png" />
	<link rel="apple-touch-icon" sizes="72x72" href="images/launch_icon_72.png" />
	<link rel="apple-touch-icon" sizes="114x114" href="images/launch_icon_114.png" />
	<link rel="stylesheet" href="jquery.mobile-1.0.1.css" />
	<link rel="stylesheet" href="custom.css" />
	<script src="js/jquery-1.7.1.min.js"></script>
	<script src="js/jquery.xml2json.js"></script>
	<script src="js/jquery.mobile-1.0.1.js"></script>
	<script src="js/json2.js"></script>
</head> 

<body> 
<div data-role="page" id="home" data-theme="c">

	<div data-role="content">
	
	<div id="branding">
		<h1>Restaurant Picker </h1>
	</div>
	
	<div class="choice_list"> 
	<h1> Select your choice!! </h1>
	
	<ul data-role="listview" data-inset="true" >
	<li><a href="verticals.html" data-transition="slidedown"> <h3> PeerFly Offers</h3></a></li>
	<li><a href="choose_town.html"  data-transition="slidedown">  <h3> Offer Verticals </h3></a></li>
	<li><a href="choose_town.html"  data-transition="slidedown">  <h3> Top Converting Offers</h3></a></li> 
	<li><a href="choose_town.html"  data-transition="slidedown">  <h3> New Offers</h3></a></li>
	</ul>	
	
	</div>
	</div>

</div><!-- /page -->
 
 <script type="text/javascript">
 		function onSuccess(data){
 			var db = openDatabase('PeerCafeApp', '1.0', 'Test DB', 2 * 1024 * 1024);
 			 var xml=data;
 			db.transaction(function (tx) {  
 			   tx.executeSql('CREATE TABLE IF NOT EXISTS offers (offerId unique,title,description,link,pubDate,verticals,payout, cr,epc,type,countries,search,social,email,web,contextual,brokering,other_restrictions,reporting,banners)');
 			   for(var i=0;i<data.length;i++){
 				   //data[i].offerID unique, data[i].title, data[i].description, data[i].link, data[i].pubDate, data[i].verticals, data[i].payout, data[i]. cr, data[i].epc, data[i].type, data[i].countries, data[i].search, data[i].social, data[i].email, data[i].web, data[i].contextual, data[i].brokering, data[i].other_restrictions, data[i].reporting, data[i].banners
				//tx.executeSql('INSERT INTO offers (offerId,title,description,link,pubDate,verticals,payout, cr,epc,type,countries,search,social,email,web,contextual,brokering,other_restrictions,reporting,banners) values ('+data[i].offerID+','+ data[i].title+','+ data[i].description+','+ data[i].link+','+ data[i].pubDate+','+ data[i].verticals+','+ data[i].payout+','+ data[i]. cr+','+ data[i].epc+','+ data[i].type+','+ data[i].countries+','+ data[i].search+','+ data[i].social+','+ data[i].email+','+ data[i].web+','+ data[i].contextual+','+ data[i].brokering+','+ data[i].other_restrictions+','+ data[i].reporting+','+ data[i].banners+')');
				console.log('INSERT INTO offers (offerId,title,description,link,pubDate,verticals,payout, cr,epc,type,countries,search,social,email,web,contextual,brokering,other_restrictions,reporting,banners) values ("'+data[i].offerID+'","'+ data[i].title+'","'+ data[i].description+'","'+ data[i].link+'","'+ data[i].pubDate+'","'+ data[i].verticals+'","'+ data[i].payout+'","'+ data[i]. cr+'","'+ data[i].epc+'","'+ data[i].type+'","'+ data[i].countries+'","'+ data[i].search+'","'+ data[i].social+'","'+ data[i].email+'","'+ data[i].web+'","'+ data[i].contextual+'","'+ data[i].brokering+'","'+ data[i].other_restrictions+'","'+ data[i].reporting+'","'+ data[i].banners+'")');
 				   
 			   }
 			  tx.executeSql('COMMIT');
 			  tx.executeSql('SELECT * FROM offers', [], function (tx, results) {
 	 			   var len = results.rows.length, i;
 	 			   msg = "<p>Found rows: " + len + "</p>";
 	 			   
 	 			   for (i = 0; i < len; i++){
 	 				  console.log('  data'+results.rows.item(i).offerID); 
 	 			   }
 	 			 }, null);
 			});
 			
 			db.transaction(function (tx) {
 			   tx.executeSql('SELECT * FROM offers', [], function (tx, results) {
 			   var len = results.rows.length, i;
 			   msg = "<p>Found rows: " + len + "</p>";
 			   
 			   for (i = 0; i < len; i++){
 				  console.log('  data'+results.rows.item(i).offerID); 
 			   }
 			 }, null);
 			});
 		}

       $(document).ready(function() {   
        $.ajax({
            type: "GET",
            url: "/PeerCafeApp/aga/pf/offers/getPopularFeed",
            cache: false, 
            dataType:"json",
            success: onSuccess
        }); 
  
     });
    </script> 	
</body>
</html>
